<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="entity.Emp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>emplist</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="css/style.css" />
	</head>
	<body>
		<div id="wrap">
			<div id="top_content">
				<%@include file="header.jsp" %>
				<div id="content">
					<p id="whereami">
					</p>
					<h1>
						Welcome!
					</h1>
					<table class="table">
						<tr class="table_header">
							<td>
								ID
							</td>
							<td>
								Name
							</td>
							<td>
								Salary
							</td>
							<td>
								Age
							</td>
							<td>
								Operation
							</td>
						</tr>
						<%
							List<Emp> list =(List<Emp>)request.getAttribute("emps");
							if(list==null){
							
							%>
							<tr class="row1">
							<td colspan="5" align="center">no data</td>
							</tr>
							<%
							}else{
							
							
							for (int i = 0; i < list.size(); i++) {
							Emp e = list.get(i);
						%>
						<tr class="row<%=i%2+1 %>">
							<td>
								<%=e.getId() %>
							</td>
							<td>
								<%=e.getName() %>
							</td>
							<td>
								<%=e.getSalary() %>
							</td>
							<td>
								<%=e.getAge() %>
							</td>
							<td>
								<a href="delete.do?id=<%=e.getId() %> " onclick="return confirm('删除？')">delete emp</a>&nbsp;
								<a href="loadEmp.do?id=<%=e.getId() %>">update emp</a>
							</td>
						</tr>
						<%
							}
							}
						%>

					</table>
					<p>
						<input type="button" class="button" value="Add Employee"
							onclick="location='addEmp.jsp'" />
					</p>
				</div>
			</div>
			<%@include file="footer.jsp" %>
		</div>
	</body>
</html>
